#!/bin/sh
################################################################################
# avahi
################################################################################
. /etc/rc.d/functions

start() {

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/avahi] Starting..."
    # mm_message_output info "Starting AVAHI..."

    if [ "x${MM_AVAHI_ENABLED}" = "xyes" ] ; then

        /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/avahi] Starting avahi daemon..."

        /usr/sbin/avahi-daemon --daemonize --file=/etc/avahi/avahi-daemon.conf

        /usr/bin/avahi-publish-http-logs-service &
        /usr/bin/avahi-publish-http-mainpage-service &
        /usr/bin/avahi-publish-telnet-service &

        /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/avahi] Started with return code=0..."

    fi
}

stop() {
    if [ "x${MM_AVAHI_ENABLED}" = "xyes" ] ; then

        /usr/bin/killall avahi-publish

        mm_message_output info "stopping avahi ..."

        /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/avahi] Stopping avahi daemon..."

        /usr/bin/killall avahi-daemon > /dev/null

    fi
}

case $1 in
    start) start ;;
    stop)  stop  ;;
esac

exit 0
